package authoritah.ui.member.popup;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JDialog;
import javax.swing.text.BadLocationException;

import authoritah.db.Member;


public class MemberPopupController {

	private MemberPopupModel model;
	private MemberPopupView view;
	
	public MemberPopupController() {
		model = new MemberPopupModel();
		view = new MemberPopupView(model);
		
		init();
	}
	
	public MemberPopupController(Member member) {
		model = new MemberPopupModel();
		view = new MemberPopupView(model, member);
		
		init();
	}
	
	public void init() {
		view.setSaveAction(new AbstractAction("Save") { //TODO adapt to take into account editing members.
			public void actionPerformed(ActionEvent e) {
				view.hide();
			}
		});
	}
	
	public JDialog getDialog() {
		return view;
	}
	
	public MemberPopupModel getModel() {
		return model;
	}
}
